package com.javasm.adminapi.module.product1.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javasm.adminapi.module.product1.dao.GgGoodsDao;
import com.javasm.adminapi.module.product1.entity.GgGoods;
import com.javasm.adminapi.module.product1.service.GgGoodsService;
import com.javasm.adminapi.module.product1.vo.SearchVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品管理-商品管理(GgGoods)表服务实现类
 *
 * @author makejava
 * @since 2025-10-15 20:31:10
 */
@Service("ggGoodsService")
public class GgGoodsServiceImpl extends ServiceImpl<GgGoodsDao, GgGoods> implements GgGoodsService {


    @Resource
    GgGoodsDao ggGoodsDao;
    @Override
    public List<GgGoods> getListBySupplierId(Integer supplierId) {
        List<GgGoods> list =ggGoodsDao.selectGoodsBySupplierId(supplierId);
        return list;
    }

    @Override
    public PageInfo<GgGoods> listAllWithTypeName(SearchVo searchVo) {
        Integer pageNum = searchVo.getPageNum();
        Integer pageSize = searchVo.getPageSize();
        if (pageNum==null||pageNum<=0){
            pageNum=1;
        }
        if (pageSize==null||pageSize<=0){
            pageSize=6;
        }
        PageHelper.startPage(pageNum,pageSize);

        List<GgGoods> list =ggGoodsDao.selectAllWithTypeName(searchVo);
        PageInfo<GgGoods> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}

